#pragma once
#ifndef __VECTOR3_H
#define __VECTOR3_H

#include<iostream>

namespace lxj{
    class Vector3
    {
    private:
        double m_x;
        double m_y;
        double m_z;
    public:
        explicit Vector3(const double x=0,const double y=0,const double z=0);
        Vector3(const Vector3& other);
        Vector3(Vector3&& other);
        Vector3& operator=(const Vector3& other);

        /************运算符重载***************/
        const bool operator ==(const Vector3& other);
        Vector3 operator -()const;
        Vector3 operator *(const float scalar) const;
        Vector3& operator *=(const float scalar);
        Vector3 operator /(const float scalar) const;
        Vector3& operator /=(const float scalar);
        Vector3 &operator +=(const Vector3 &lhs);
        Vector3 &operator -=(const Vector3 &lhs);

        /*************friend*******************/
        friend Vector3 operator *(const float scalar, const Vector3 &vector);
        friend Vector3 operator /(const float scalar, const Vector3 &vector);
        friend const Vector3 operator +(const Vector3 &rhs, const Vector3 &lhs);
        friend const Vector3 operator -(const Vector3 &rhs, const Vector3 &lhs);
        friend const double operator *(const Vector3 &rhs, const Vector3 &lhs);
        friend const Vector3 crossProduct(const Vector3 &rhs, const Vector3 &lhs);

        /*************查看******************/
        void print()const;

        //模长
        const double getLength()const;

        //单位向量
        const Vector3 normalized()const;

        //~Vector3();
    };

    struct Matrix3x3
    {
        float mm11,mm12,mm13;
        float mm21,mm22,mm23;
        float mm31,mm32,mm33;
    
    public:
        Matrix3x3(float m11=0, float m12=0, float m13=0, 
                  float m21=0, float m22=0, float m23=0,
                  float m31=0, float m32=0, float m33=0);
        ~Matrix3x3();

        /*****************运算符重载********************/
        const bool operator ==(const Matrix3x3 &lhs) const;
        friend const Matrix3x3 operator *(const Matrix3x3 &rhs, const Matrix3x3 &lhs);
    };

    //计算两个Vector3的叉乘
    const Vector3 crossProduct(const Vector3 &rhs, const Vector3 &lhs);

    //计算两个向量的夹角，θ为弧度制(360=2π=6.28...)
    const double angle(const Vector3 &rhs, const Vector3 &lhs);

    //快速知道两个向量是否同向(两个向量之间的夹角小于90°为同向，也就是cos大于0)
    //返回1为同向，0为垂直，-1为反向
    const short isSameDirector(const Vector3 &rhs, const Vector3 &lhs);
}

#endif